package org.jb.coinche.client.gin;

import java.util.HashSet;
import java.util.Set;

import org.jb.coinche.client.business.handler.DisconnectHandler;
import org.jb.coinche.client.business.handler.impl.DisconnectHandlerImpl;
import org.jb.coinche.client.business.handler.impl.GUIAuctionTurnHandler;
import org.jb.coinche.client.business.handler.impl.GUICoincheHandler;
import org.jb.coinche.client.business.handler.impl.GUIGameHandler;
import org.jb.coinche.client.business.handler.impl.GUIRoundFinishedHandler;
import org.jb.coinche.client.business.handler.impl.GUIRoundTurnFinishedHandler;
import org.jb.coinche.client.business.handler.impl.GUIRoundTurnHandler;
import org.jb.coinche.client.guistatemachine.GUIStateHandler;
import org.jb.coinche.client.guistatemachine.MessageSender;
import org.jb.coinche.client.guistatemachine.MessageSenderImpl;
import org.jb.coinche.client.guistatemachine.State;

import com.google.gwt.inject.client.AbstractGinModule;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.TypeLiteral;

public class CoincheModule extends AbstractGinModule {

	@Override
	protected void configure() {
		bind( MessageSender.class ).to( MessageSenderImpl.class );
		bind( DisconnectHandler.class ).to( DisconnectHandlerImpl.class );
		bind( new TypeLiteral<Set<GUIStateHandler<? extends State> > >() {} ).toProvider(HandlersProvider.class);
	}

	/*
	 * 
	 */
	public static class HandlersProvider implements Provider< Set<GUIStateHandler<? extends State> > > {

		@Inject
		private GUIAuctionTurnHandler h1;
		
		@Inject
		private GUIGameHandler h2;
		
		@Inject
		private GUIRoundFinishedHandler h3;
		
		@Inject
		private GUIRoundTurnFinishedHandler h4;
		
		@Inject
		private GUIRoundTurnHandler h5;
		
		@Inject
		private GUICoincheHandler h6;
		
		@Override
		public Set<GUIStateHandler<? extends State>> get() {
			HashSet< GUIStateHandler<? extends State > > set = new HashSet< GUIStateHandler<? extends State > >();
			set.add(h1);
			set.add(h2);
			set.add(h3);
			set.add(h4);
			set.add(h5);
			set.add(h6);
			return set;
		}
		
	}
	
}
